var _excluded = ['children', 'mode', 'className'];
function _extends() {
  _extends = Object.assign
    ? Object.assign.bind()
    : function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];
          for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }
        return target;
      };
  return _extends.apply(this, arguments);
}
function _objectWithoutProperties(source, excluded) {
  if (source == null) return {};
  var target = _objectWithoutPropertiesLoose(source, excluded);
  var key, i;
  if (Object.getOwnPropertySymbols) {
    var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
    for (i = 0; i < sourceSymbolKeys.length; i++) {
      key = sourceSymbolKeys[i];
      if (excluded.indexOf(key) >= 0) continue;
      if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
      target[key] = source[key];
    }
  }
  return target;
}
function _objectWithoutPropertiesLoose(source, excluded) {
  if (source == null) return {};
  var target = {};
  var sourceKeys = Object.keys(source);
  var key, i;
  for (i = 0; i < sourceKeys.length; i++) {
    key = sourceKeys[i];
    if (excluded.indexOf(key) >= 0) continue;
    target[key] = source[key];
  }
  return target;
}
import React, { forwardRef } from 'react';
// @ts-ignore

import { AutoComplete as AntdAutoComplete, Input } from 'antd';
import classnames from 'classnames';
import { useFieldContext } from '../_utils/contexts/FieldContext';
import createField from '../createField';
/**
 * 自动完成，扩展输入框、文本框、搜索框三种展示模式
 * @param props
 * @returns
 */
var AutoComplete = /*#__PURE__*/ forwardRef(function (_ref, ref) {
  var children = _ref.children,
    _ref$mode = _ref.mode,
    mode = _ref$mode === void 0 ? 'input' : _ref$mode,
    className = _ref.className,
    rest = _objectWithoutProperties(_ref, _excluded);
  var _useFieldContext = useFieldContext(),
    label = _useFieldContext.label;
  var node = null;
  var placeholder = '';
  console.log('rest', rest);
  switch (mode) {
    case 'textarea':
      node = /*#__PURE__*/ React.createElement(Input.TextArea, {
        placeholder: placeholder,
        className: 'custom',
        style: {
          height: 50,
        },
      });
      placeholder = '\u8BF7\u8F93\u5165'.concat(
        label || '',
        '\uFF0C\u6216\u9009\u62E9\u5339\u914D\u9879',
      );
      break;
    case 'search':
      node = /*#__PURE__*/ React.createElement(Input.Search, {
        placeholder: placeholder,
        enterButton: true,
      });
      placeholder = '\u8BF7\u641C\u7D22';
      break;
    default:
      placeholder = '\u8BF7\u8F93\u5165'.concat(
        label || '',
        '\uFF0C\u6216\u9009\u62E9\u5339\u914D\u9879',
      );
      break;
  }
  return /*#__PURE__*/ React.createElement(
    AntdAutoComplete,
    _extends(
      {
        ref: ref,
        placeholder: placeholder,
        className: classnames('szzj-auto-complete', className),
      },
      rest,
    ),
    children !== null && children !== void 0 ? children : node,
  );
});
export default createField(AutoComplete);
